home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 1.toast / pc / sample code / devices and hardware / scsi / scsi driveid sample / showalldrivequeueelements.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  2.2 KB  |  91 lines

  1. /*
  2.     File:        ShowAllDriveQueueElements.c
  3.  
  4.     Contains:    This subroutine scans the linked list of drive queue elements and displays
  5.                 information about each active drive.
  6.  
  7.     Written by: Martin Minow    
  8.  
  9.     Copyright:    Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.                 You may incorporate this Apple sample source code into your program(s) without
  12.                 restriction. This Apple sample source code has been provided "AS IS" and the
  13.                 responsibility for its operation is yours. You are not permitted to redistribute
  14.                 this Apple sample source code as "Apple sample source code" after having made
  15.                 changes. If you're going to re-distribute the source, we require that you make
  16.                 it clear in the source that the code was descended from Apple sample source
  17.                 code, but that you've made changes.
  18.  
  19.     Change History (most recent first):
  20.                 7/14/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  21.                 
  22.  
  23. */
  24. #include <stdio.h>
  25. #include <Files.h>
  26. #include <Devices.h>
  27.  
  28. void                    ShowAllDriveQueueElements(void);
  29. void                    ShowOneDriveQueueElement(
  30.         register DrvQEl        *drvQElPtr
  31.     );
  32. void                    ShowSCSIDeviceIdent(
  33.         short                driverRefNum
  34.     );
  35.  
  36. void
  37. ShowAllDriveQueueElements(void)
  38. {
  39.         register DrvQEl        *drvQElPtr;
  40. #define DQEL    (*drvQElPtr)
  41.  
  42.         drvQElPtr = (DrvQEl *) GetDrvQHdr()->qHead;
  43.         while (drvQElPtr != NULL) {
  44.             ShowOneDriveQueueElement(drvQElPtr);
  45.             drvQElPtr = (DrvQEl *) drvQElPtr->qLink;
  46.         }
  47. #undef DQEL
  48. }
  49.  
  50. void
  51. ShowOneDriveQueueElement(
  52.         register DrvQEl        *drvQElPtr
  53.     )
  54. {
  55. #define DQEL    (*drvQElPtr)
  56.  
  57.         printf("Drive %2d, driver %3d,", (int) DQEL.dQDrive, (int) DQEL.dQRefNum);
  58.         switch (DQEL.qType) {
  59.         case 0:
  60.             printf(
  61.                 "%8lu blocks (small drive)",
  62.                 (unsigned long) DQEL.dQDrvSz
  63.             );
  64.             break;
  65.         case 1:
  66.             printf(
  67.                 "%8lu blocks (large drive)",
  68.                 ((unsigned long) DQEL.dQDrvSz)
  69.                 + (((unsigned long) DQEL.dQDrvSz2) * 0x10000L)
  70.             );
  71.             break;
  72.         case 3:
  73.             printf(
  74.                 "%8lu blocks (MFS present)",
  75.                 ((unsigned long) DQEL.dQDrvSz)
  76.             );
  77.             break;
  78.         default:
  79.             printf(
  80.                 "%lu %lu blocks (unknown queue type)",
  81.                 ((unsigned long) DQEL.dQDrvSz),
  82.                 ((unsigned long) DQEL.dQDrvSz2)
  83.             );
  84.             break;
  85.         }
  86.         ShowSCSIDeviceIdent(DQEL.dQRefNum);
  87.         printf("\n");
  88. #undef DQEL
  89. }
  90.  
  91.